//
//  PublicStringConvert.m
//  PersonnelRegister
//
//  Created by mac on 14-5-23.
//  Copyright (c) 2014年 江苏宏创. All rights reserved.
//

#import "HCPublicStringConvert.h"

static HCPublicStringConvert *instance = nil;

@implementation HCPublicStringConvert

+ (HCPublicStringConvert *)sharePublicStringConvert
{
    if(!instance)
    {
        instance = [[HCPublicStringConvert alloc] init];
    }
    return instance;
}

- (NSDictionary *)convertDic:(NSData *)paramData
{
    NSError *error;
    NSString *jsonString = [[NSString alloc] initWithData:paramData
                                                 encoding:NSUTF8StringEncoding];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"null" withString:@"\"\""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"<null>" withString:@""];
    
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"\\r\\n" withString:@"<br/>"];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"  " withString:@"&nbsp&nbsp"];
    NSLog(@"MMMNN-->%@",jsonString);
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"&rdquo;" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"&ldquo;" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"&middot;" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"&rsquo;s" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"&rsquo;" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"&lsquo;" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"&bull" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"&mdash;" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"&hellip;" withString:@""];
    jsonString = [jsonString stringByReplacingOccurrencesOfString:@"&quot;" withString:@""];
//    NSLog(@"jsonString-->%@",jsonString);
    NSData *convertData = [jsonString dataUsingEncoding: NSUTF8StringEncoding];
    NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:convertData options:NSJSONReadingMutableLeaves error:&error];
    
//    NSLog(@"convertDic-->%@",dic);
    return dic;
}

@end
